<?php
defined('_JEXEC') or die('Restricted Access');
JHtml::_('behavior.tooltip');
?>
<table>
	<tr>
		<td>
			<?php echo JHTML::_('select.genericlist',$_SESSION['ARRAY_LINK_WEB']	 ,'website', 'class="inputbox"','id','text',''); ?>
		</td>
		<td>
			<select id="list-of-categories">
				<option>Select Website</option>
				
			</select>
		</td>
	</tr>
</table>
<div id="filter-bar" class="btn-toolbar">
		<a  class="btn btn-small btn-success" href="index.php?option=com_link&view=links">Back to manager</a>
	</div>
<form action="index.php" method="post">
<div style="clear:both;">&nbsp;</div>
	<table id="list-of-news">
		<tr>
			<td>#</td>
			<td width="400"><strong>title</strong></td>
			<td><strong>nguoivietodessa</strong></td>
		</tr>
		
	</table>
	<input type="submit" value="Nhập">
	<input name="option" value="com_link" type="hidden" />
	<input name="type" value="" type="hidden" />
	<input name="task" value="links.save_acticle" type="hidden" />
</form>
<script>
jQuery(function(){
	var html = "<tr><td>#</td><td width='400'><strong>title</strong></td><td><strong>nguoivietodessa</strong></td></tr>";
	var htmlwaiting ="<tr><td width='500'>Sending ..... </td></tr>";
	
	jQuery('#website').change(function(){
		
		var id = jQuery(this).val();
		jQuery('input[name=type]').val(id);
		jQuery("#list-of-news").html(htmlwaiting);
		jQuery.get( "index.php?option=com_link&task=links.ajax_request_category&id="+id, function(data) {
			jQuery(".result" ).html( data );
				jQuery('#list-of-categories').html(data);
				jQuery('#list-of-news').html("<tr><td width='500'>Select Category</td></tr>");
			}
		);
	});

	jQuery('#list-of-categories').change(function(){
		jQuery("#list-of-news").html(htmlwaiting);
		var id = jQuery(this).val();
		jQuery.get( "index.php?option=com_link&task=links.ajax_request_link&id="+id, function(data) {
			jQuery(".result" ).html( data );
				jQuery("#list-of-news").html(data);
			}
		);
	});

	jQuery( "#list-of-news" ).delegate( "td select.category", "change", function() {
		
		if(jQuery(this).val()){
			jQuery(this).parents('td').prev('td').prev('td').find('input').attr('checked',true);
		}else{
			
			jQuery(this).parents('td').prev('td').prev('td').find('input').attr('checked',false);
		}
	});
})
</script>

